#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <iostream>
#include <sstream>
using namespace std;
string s;
int main(void){
    while(getline(cin,s)){
        if(s[0]=='#'){
            break;
        }
        istringstream sin(s);
        set<string> words;
        string w;
        while(sin >> w){
            words.insert(w);
        }
        printf("%d\n",words.size());
    }
    return 0;
}
